package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.ProductCategoryAttributeRelation;
import com.itheima.mapper.ProductCategoryAttributeRelationMapper;
import com.itheima.service.IProductCategoryAttributeRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 产品的分类和属性的关系表，用于设置分类筛选条件（只支持一级分类） 服务实现类
 * </p>
 *
 * @author fukeke
 * @since 2022-11-11
 */
@DubboService
public class ProductCategoryAttributeRelationServiceImpl extends ServiceImpl<ProductCategoryAttributeRelationMapper, ProductCategoryAttributeRelation> implements IProductCategoryAttributeRelationService {
    @Autowired
    ProductCategoryAttributeRelationMapper productCategoryAttributeRelationMapper;

    @Override
    public List<ProductCategoryAttributeRelation> findByProductCategoryId(Long productCategoryId) {
        LambdaQueryWrapper<ProductCategoryAttributeRelation> qw=new LambdaQueryWrapper<>();
        qw.eq(ProductCategoryAttributeRelation::getProductCategoryId,productCategoryId);
        return productCategoryAttributeRelationMapper.selectList(qw);
    }

    @Override
    public void deleteByCid(Long id) {
        LambdaQueryWrapper<ProductCategoryAttributeRelation> qw=new LambdaQueryWrapper<>();
        qw.eq(ProductCategoryAttributeRelation::getProductCategoryId,id);
        productCategoryAttributeRelationMapper.delete(qw);
    }

    @Override
    public void create(ProductCategoryAttributeRelation relation) {
        productCategoryAttributeRelationMapper.insert(relation);
    }
}
